package com.jboltai.event.signal;

import com.jboltai.event.Event;
import com.jboltai.event.EventErrorType;
import com.jboltai.event.EventState;
import com.jboltai.event.EventType;
import com.jboltai.event.handler.SuccessEventHandler;

import static com.jboltai.event.EventType.SIGNAL_SUCCESS;


/**
 * 特殊事件。不会执行onFail回调
 */
public class SuccessEvent extends Event<SuccessEvent,Object, SuccessEventHandler> {


    public SuccessEvent() {
        super(SIGNAL_SUCCESS);
    }
    public SuccessEvent(Object data) {
        super(SIGNAL_SUCCESS);
        this.result = data;
    }

    protected SuccessEvent(EventType type) {
        super(SIGNAL_SUCCESS);
    }

    @Override
    public String preCheck() {
        return null;
    }

    @Override
    public void fail(EventErrorType errorType) {

    }

    @Override
    public void success(Object result) {
        super.success(result);
        this.setState(EventState.SUCCESS);
        this.complete();
    }
}
